<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>十进制转换为二进制或十六进制</title>
</head>
<body>
    <script>
        const num = 10;

        // num.toString(2);
        console.log('%c   num.toString(2): 十进制转二进制','color: MidnightBlue; background: Aquamarine; font-size: 20px;', num.toString(2));
        // 输出: "1010"
        // num.toString(16);
        console.log('%c   num.toString(16): 十进制转十六进制','color: MidnightBlue; background: Aquamarine; font-size: 20px;', num.toString(16));
        // 输出: "a"
        // num.toString(8);
        console.log('%c   num.toString(8): 十进制转八进制','color: MidnightBlue; background: Aquamarine; font-size: 20px;', num.toString(8));
        // 输出: "12"

    </script>
</body>
</html>